/*--------------------------------------------------------------------------------
	Hujub Exporter	Animation Struxtures
				by Hujub SungiL
	
	HISTORY	: 2005_10_16

    LAST UPDATE : 2005_10_16
--------------------------------------------------------------------------------*/
#pragma once

#define		_STLP_USE_NEWALLOC

#include	"Max.h"
#include	"istdplug.h"
#include	"iparamb2.h"
#include	"iparamm2.h"
#include	"stdmat.h"
#include	"decomp.h"
#include	"phyexp.h"
#include	"bipexp.h"
#include	"resource.h"
#include	<vector>
#include	<windows.h>
#include	<d3dx9.h>
#include	".\\Public\\HJ_Define.h"

/*-----------------------------------------------------
					BIPED
-----------------------------------------------------*/
struct	BipMesh
{
	D3DXVECTOR3*			pBipVertex;
	WORD*					pIndex;
	LPDIRECT3DVERTEXBUFFER9	pVB;
	LPDIRECT3DINDEXBUFFER9	pIB;
	int						nVertex;
	int						nFace;
};


/*-----------------------------------------------------
					ANIMATION
-----------------------------------------------------*/
struct	AnimLink
{
    int						nIndex;
	Quat					qRS;
	Point3					vPS;
	AnimLink*				pNext;
	AnimLink*				pPrev;

	void	Add( AnimLink* pAnim ) {
		if( pNext )	pNext->Add( pAnim );
		else
		{
			pNext = pAnim;
			pAnim->pPrev	= this;
		}
	}
};

struct	AnimationMng
{
    AnimLink*		pPosTrack;
	AnimLink*		pRotTrack;
	AnimLink*		pSclTrack;
	int				nPosTrack;
	int				nRotTrack;
	int				nScaleTrack;
	AffineParts		ap;
};


/*-----------------------------------------------------
						MESH
-----------------------------------------------------*/
struct	Ani_FaceIndex
{
	WORD	pIndex[3];
};

struct	Ani_Mesh
{
    D3DXVECTOR3*	pVertexList;
	Ani_FaceIndex*	pFaceIndex;

	int				nVertex;
	int				nFace;
};

/*-----------------------------------------------------
					ANOTHER
-----------------------------------------------------*/
struct	Ani_Others
{
	TCHAR			szName[256];
	TCHAR			szParentName[256];
	AffineParts		ap;
};

struct	Ani_MatrixMng
{
	D3DXMATRIX		matWorld;
	D3DXMATRIX		matInverse;
	D3DXMATRIX		matLocal;
};

struct	Scene
{
	int		nLastFrame;
	int		nFrameRate;
	int		nTickPerFrame;
	int		nTickPerSeond;
};

struct	Ani_Geom
{
	AnimationMng		AnimMng;
	Ani_Others			Orthers;
	Ani_MatrixMng		MatMng;
	Ani_Mesh			MeshMng;

	Ani_Geom*			pParent;
	INode*				pParentINode;
	Ani_Geom*			pNext;
	Ani_Geom*			pPrev;

	void	Add( Ani_Geom*	pGeom )
	{
		if( pNext )	pNext->Add( pGeom );
		else
		{
			pNext	= pGeom;
			pGeom->pPrev	= this;
		}
	}
};
